package demoMod.stsconsole.relics;

import demoMod.stsconsole.dungeons.AbstractDungeon;
import demoMod.stsconsole.interfaces.ISubscriber;
import demoMod.stsconsole.interfaces.RelicLoseSubscriber;
import demoMod.stsconsole.interfaces.RelicObtainSubscriber;

public class Circlet extends AbstractRelic implements RelicObtainSubscriber, RelicLoseSubscriber {
    public static final String ID = "Circlet";

    public Circlet() {
        super(ID);
        this.rarity = RelicRarity.SPECIAL;
        this.color = RelicColor.SHARED;
        this.counter = 1;
    }

    @Override
    public String getUpdatedDescriptions() {
        return this.description;
    }

    @Override
    public boolean onEquip(AbstractRelic relic) {
        if (ID.equals(relic.id)) {
            if (AbstractDungeon.player.hasRelic(ID)) {
                AbstractDungeon.player.getRelic(ID).counter++;
            }
            return !AbstractDungeon.player.hasRelic(ID);
        } else {
            return true;
        }
    }

    @Override
    public boolean enabled(Class<? extends ISubscriber> cls) {
        return cls.getSimpleName().equals("ReloadStringsSubscriber") || (AbstractDungeon.player != null);
    }

    @Override
    public boolean onUnequip(AbstractRelic relic) {
        if (ID.equals(relic.id)) {
            if (AbstractDungeon.player.hasRelic(ID)) {
                AbstractDungeon.player.getRelic(ID).counter--;
                return AbstractDungeon.player.getRelic(ID).counter <= 0;
            }
        }
        return true;
    }
}
